You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When flet_code_editor is used with CodeLanguage.JSON, invalid JSON did not produce gutter error markers. The root cause was that JSON mode still relied on the default local analyzer, which does not perform real JSON syntax validation.
This change adds a JSON-specific analyzer in the Flutter extension layer. It validates editor content with dart:convert, converts FormatException into editor Issues, and maps the error to the correct line so the gutter can render the marker. Non-JSON languages keep their existing analyzer behavior.
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
This change requires a documentation update
Checklist
I signed the CLA.
My code follows the style guidelines of this project
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
My changes generate no new warnings
New and existing tests pass locally with my changes
I have made corresponding changes to the documentation (if applicable)
Screenshots
Before
After
Additional details
Local validation:
flutter test test/json_gutter_analyzer_test.dart
flutter analyze lib/src/utils/flet_code_controller.dart lib/src/utils/json_analyzer.dart test/json_gutter_analyzer_test.dart
Summary by Sourcery
Add a JSON-specific analyzer for the Flutter code editor to surface JSON syntax errors as gutter issues while preserving existing behavior for other languages.
Bug Fixes:
Ensure invalid JSON content in the code editor is reported as error issues with correct line mapping in the gutter.
Tests:
Add unit tests verifying that JSON language uses the JSON analyzer, reports invalid JSON syntax as a single error issue, and leaves valid JSON without issues.
I've been wondering if it's possible, instead of adding analyzers on Dart side, to make some sort of event handler, like on_analyze, do analyze on Python side and push results back to CodeEditor control? Cause going forward I guess we need analyzers for more languages, such as Python, right?
I've been wondering if it's possible, instead of adding analyzers on Dart side, to make some sort of event handler, like on_analyze, do analyze on Python side and push results back to CodeEditor control? Cause going forward I guess we need analyzers for more languages, such as Python, right?
Thanks for the guidance on moving analysis to the Python side.
I reworked the implementation accordingly and opened a new PR: #6411
This new version replaces the JSON-specific Dart analyzer with a generic on_analyze + issues flow, so analyzer logic can be handled on Python side for multiple languages.
Would you mind taking a look when you have time?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6312.
When
flet_code_editoris used withCodeLanguage.JSON, invalid JSON did not produce gutter error markers. The root cause was that JSON mode still relied on the default local analyzer, which does not perform real JSON syntax validation.This change adds a JSON-specific analyzer in the Flutter extension layer. It validates editor content with
dart:convert, convertsFormatExceptioninto editorIssues, and maps the error to the correct line so the gutter can render the marker. Non-JSON languages keep their existing analyzer behavior.Test Code
Type of change
Checklist
Screenshots
Before
After
Additional details
Local validation:
flutter test test/json_gutter_analyzer_test.dart flutter analyze lib/src/utils/flet_code_controller.dart lib/src/utils/json_analyzer.dart test/json_gutter_analyzer_test.dartSummary by Sourcery
Add a JSON-specific analyzer for the Flutter code editor to surface JSON syntax errors as gutter issues while preserving existing behavior for other languages.
Bug Fixes:
Tests: